﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormApp
{
    public partial class UCHexFormatControl : UserControl
    {
        public UCHexFormatControl()
        {
            InitializeComponent();
        }

        private void UCHexFormatControl_Load(object sender, EventArgs e)
        {

        }

        private void btnFormat_Click(object sender, EventArgs e)
        {
            try
            {
                rtxtDst.Text = string.Empty;

                string[] strs = rtxtSrc.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                StringBuilder sb = new StringBuilder();
                int colCount = (int)numColCount.Value;

                for (int i = 0; i < strs.Length; i++)
                {
                    if (i > 0 && i % colCount == 0)
                    {
                        sb.AppendLine();
                    }

                    sb.Append(strs[i]);
                    sb.Append(' ');
                }

                rtxtDst.Text = sb.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
